﻿<div class="content-wrapper">
    <section class="content-header">
        <h1>
            巡检管理
            <small>历史巡检记录</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">巡检管理</a></li>
            <li class="active">历史巡检记录</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body">
                        <div class="form-inline">
                            <label>站点</label>
                            <input type="text" v-model="search1" ref="search1" id="search1" class="form-control">
                            <label>设备名称</label>
                            <input type="text" v-model="search2" ref="search2" id="search2" class="form-control">
                            <label>巡检人员</label>
                            <input type="text" v-model="search3" ref="search3" id="search3" class="form-control">

                            <label>开始时间</label>
                            <input type="text" v-model="datemin" ref="datemin" id="datemin" class="form-control">
                            <label>结束时间</label>
                            <input type="text" v-model="datemax" ref="datemax" id="datemax" class="form-control">

                        </div>
                        <div id="toolbar" class="btn-group">
                            <button id="btn_search" v-on:click="searchL" type="button" class="btn btn-default">
                                <span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询
                            </button>
                        </div>
                        <table id="bootstraptable" class="table table-bordered text-nowrap table-hover"></table>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
@section scripts{
    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                datemin: '',
                datemax: '',
                search1: '',
                search2: '',
                search3: '',
                clientWidth: document.body.clientWidth,//获取设备屏幕的宽度
            },
            mounted: function () {
                var _self = this;
                _self.$nextTick(function () {
                    //显示active
                    _self.$refs.InspectionHistory.parentNode.parentNode.classList.add("active");
                    _self.$refs.InspectionHistory.classList.add("active");

                    _self.datemin = _self.getCurrentMonthFirst();
                    _self.datemax = _self.getCurrentMonthLast();
                    $('#datemin').datetimepicker({
                        format: 'yyyy-mm-dd',
                        minView: 2,
                        autoclose: true,
                        language: "zh-CN"
                    });
                    $('#datemax').datetimepicker({
                        format: 'yyyy-mm-dd',
                        minView: 2,
                        autoclose: true,
                        language: "zh-CN"
                    });
                    setTimeout(function () {
                        _self.loadL();
                        setDataCardView("#bootstraptable");
                    }, 500);
                });
            },
            methods: {
                loadL: function () {
                    _self = this;
                    var obj = [{
                        checkbox: true,             //是否显示复选框
                        visible: true
                    }, {
                        field: 'InspectionId',
                        title: 'InspectionId',
                        visible: false
                    }, {
                        field: 'ClientName',
                        title: '站点',
                        align: 'center',
                        sortable: true
                    }, {
                        field: 'DeviceName',
                        align: 'center',
                        title: '设备名称'
                    }, {
                        field: 'Inspector',
                        title: '巡检人员',
                        align: 'center',
                        sortable: true
                    }, {
                        field: 'CreateTime',
                        title: '巡检时间',
                        align: 'center',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return _self.jsonDateFormat(value);
                        }
                    }, {
                        field: 'IsNormal',
                        title: '巡检结果',
                        align: 'center',
                        sortable: true,
                        formatter: function (value, row, index) {
                            if (row.Flag == 0) {
                                return '-';
                            } else {
                                if (value == 0) {
                                    return '<label class="label-success" style="padding:5px 10px">正常</label>';
                                } else {
                                    return '<label class="label-danger" style="padding:5px 10px">异常</label>';
                                }
                            }

                        }
                    }, {
                        field: 'Remark',
                        align: 'center',
                        title: '备注'
                    }];
                    yui.table("bootstraptable", "/InspectionHistory/List", obj, "POST", "ClientId", false, false, "InspectionTime", "desc", true, true, true, true);
                },
                searchL: function () {
                    $("#bootstraptable").bootstrapTable('refresh');
                }
            }
        });


    </script>
}